﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace CPPEI.Coolzon.DisplayApp
{
    public class MouseMonitorHelper
    {
        private static Point _mousePosition;    //鼠标的位置
        private static int _checkCount;
        private static double _deltaX;
        private static double _deltaY;
        
        /// <summary>
        /// true:鼠标没有移动了
        /// false:鼠标有移动
        /// </summary>
        /// <returns></returns>
        public static bool IsMouseHover()
        {
            if (_deltaX == 0 && _deltaY == 0)
            {
                _checkCount++;
            }
            else
            {
                _deltaX = 0;
                _deltaY = 0;
            }

            if (_checkCount > 3)
            {
                return true;
            }
            return false;
        }

        public static void UpdatePoint(Point curPos)
        {
            _deltaX = curPos.X - _mousePosition.X;
            _deltaY = curPos.Y - _mousePosition.Y;
            _mousePosition = curPos;
            if (_deltaX != 0 || _deltaY != 0)
            {
                _checkCount = 0;
            }
        }
    }
}
